<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
 <%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
 <head>
  <title>菜单表</title>
  <link rel="stylesheet" type="text/css" href="${ctx}/css/easyui/themes/gray/easyui.css">
	<link rel="stylesheet" type="text/css" href="${ctx}/css/easyui/demo.css">
	<link rel="stylesheet" type="text/css" href="${ctx}/css/easyui/grayDefault.css">
	<link rel="stylesheet" type="text/css" href="${ctx}/css/easyui/themes/icon.css">
	<link rel="stylesheet" type="text/css" href="${ctx}/js/scripts/uploadify.css">
	<script type="text/javascript" src="${ctx}/js/scripts/jquery-1.4.4.min.js"></script>
	<script type="text/javascript" src="${ctx}/js/easyui/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="${ctx}/js/easyui/src/jquery.parser.js"></script>
	 <script type="text/javascript" src="${ctx}/js/scripts/JSONUtil.js"></script>
	 <script type="text/javascript" src="${ctx}/js/easyui/local/easyui-lang-zh_CN.js"></script>
	<script type="text/javascript" src="${ctx}/js/scripts/swfobject.js"></script>
    <script type="text/javascript" src="${ctx}/js/scripts/jquery.uploadify.v2.1.0.js"></script>
    <script type="text/javascript" src="${ctx}/js/scripts/jquery.edatagrid.js"></script>
    <script type="text/javascript" src="${ctx}/js/scripts/util.js"></script>
  <script type="text/javascript">
  $(function() {
	  //控制父级菜单显示与否
	  if('${menu.level}'=='1'){
		  $("#fid").show();
		  
	  }else{
		  $("#fid").hide(); 
	  }
  });
  //菜单等级改变的时候
  function lChange(){
	  //菜单等级为一级菜单时
	  if($("#level").val()=="0"){
		  $('#pid').combotree('clear');
	 $("#pid").text("");
		  $("#fid").hide(); 
	  //菜单等级为下级菜单时
	  }else{  
		  $("#fid").show(); 
	  }
	  
  }
  
  function save(){
	//验证非空
      var retVal = $("#addMenuContent").form("validate");
      if(!retVal) {
        return false;
      } 
  
      //if (window.confirm("确定添加？")) {
        var formValues=$("#addMenuContent").serializeArray();
        $.post("${ctx}/menu/saveMenu",formValues,function(data){
          if(data.info=="success"){
        	  $.messager.alert('系统提示', '保存成功', 'info', function(){
        		  opener.location.href=opener.location.href;
                  opener=null;
                  //window.returnValue = "success";
                  window.close();
        	  });
              //保存成功
              // $.messager.alert("提示","保存成功");
              
          }else{
              //保存失败
              $.messager.alert("保存失败","系统提示", "info",function(){
            	  $('#save').attr("disabled",true);
            	  });/* 保存失败 */
            
             
          }
      });
  }
  </script>
 </head>
 <body>
  <table width="100%"  cellpadding="0" cellspacing="0" border="0">
		<tr>
			<td height="8px" >
				<form id="addMenuContent" name="addMenuContent" method="post">
					<table width="100%"  cellpadding="1" cellspacing="0" border="0">
					<tr>
		             <td colspan="2" class="t_sld l_sld r_sld dispHeader">
		                <table cellpadding="2" cellspacing="2">
		                 <tr>
		                    <td class="dispHeader">菜单管理  <!-- 基本头部 -->
		                    </td>
		                 </tr>
		                </table>
		             </td>
		            </tr>
						<tr>
							<td>
								<input type="hidden" id="id" name="id"	value="${menu.id}" />
								<input type="hidden" id="status" name="status"	value="${menu.status}" />
								<input type="hidden" id="createPerson" name="createPerson"	value="${menu.createPerson}" />
								<input type="hidden" id="createDate" name="createDate"	value="${menu.createDate}" />
								<input type="hidden" id="updatePerson" name="updatePerson"	value="${menu.updatePerson}" />
								<input type="hidden" id="updateDate" name="updateDate"	value="${menu.updateDate}" />
							</td>
						</tr>

						<tr style="min-height: 25">
							<td class="t_sld l_sld dispT" width="30%">菜单名称:</td>
							<td class="t_sld l_sld dispC r_sld dispC"><input type="text" class="easyui-validatebox w20"
								required="true" id="name" name="name"
								value="${menu.name}" /></td>
						</tr>
						

						<tr>


							<td class="t_sld l_sld dispTT" width="30%" >菜单等级:</td>
							<td class="t_sld l_sld dispC r_sld dispC">
								<select  style="width: 200px"  id="level" name="level" onchange="lChange()" >
				                   <c:forEach items="${menulevel}" var="docType">
				                    <option value="${docType.code}"
				                      <c:if test="${menu.level == docType.code}">
				                        selected="selected"
				                      </c:if>>
				                        ${docType.name}
				                    </option>
				                  </c:forEach> 
				                </select>  
                
								</td>

						</tr>
						<tr id="fid" hidden="true">


							<td class="t_sld l_sld dispTT" width="30%" >父级菜单</td>
							<td class="t_sld l_sld dispC r_sld dispC">
								<input class="easyui-combotree" value="${menu.pid }" id="pid" name="pid" data-options="url:'${ctx}/menu/getMenus',method:'get',required:true" style="width:200px;">
                
								</td>

						</tr>
						
						<tr style="min-height: 25">


							<td class="t_sld l_sld dispT" width="30%">菜单地址:</td>
							<td class="t_sld l_sld dispC r_sld dispC"><input type="text" class="easyui-validatebox w20"
								required="true" id="murl" name="murl"
								value="${menu.murl}" maxlength="21" /></td>

						</tr>
						
						<tr>
							<td class="t_sld l_sld b_sld dispTT" width="30%">菜单顺序:</td>
							<td class="t_sld l_sld  b_sld dispC r_sld dispC"><input type="text" class="easyui-validatebox w20"
								required="true" id="orderid" name="orderid"
								value="${menu.orderid}" maxlength="21" /></td>
						</tr>
					</table>
				</form>
			</td>
		</tr>

		<tr>
			<td align="center" valign="bottom"><a href="#" id="save"
				class="easyui-linkbutton" iconCls="icon-save" plain="false"
				onclick="save()">保存</a>
			<!-- 保存 --></td>
		</tr>
	</table>
 </body>